<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>商品分类</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row :gutter="10">
        <el-col :span="6">
          <el-button type="primary">添加分类</el-button>
        </el-col>
      </el-row>
      <el-table :data="categoriesList" style="width: 100%">
        <el-table-column type="index" label="序号" width="width"> </el-table-column>
        <el-table-column prop="cat_name" label="分类名称" width="width"> </el-table-column>
        <el-table-column prop="cat_deleted" label="是否有效" width="width"> 
          <template slot-scope="scope">
            <i class="el-icon-error" style="color:red" v-if="scope.row.cat_deleted"></i>
            <i class="el-icon-success" style="color:lightgreen" v-else></i>
          </template>
        </el-table-column>
        <el-table-column prop="cat_level" label="排序" width="width"> 
          <template slot-scope="scope">
                <el-tag type="primary" size="mini" v-if="scope.row.cat_level==='0'">一级</el-tag>
                <el-tag type="success" size="mini" v-else-if="scope.row.cat_level==='1'">二级</el-tag>
                <el-tag type="warning" size="mini" v-else>三级</el-tag>
            </template>
        </el-table-column>
        <el-table-column label="操作" width="width"> 
            <el-button type="primary" size="mini" class="el-icon-edit">编辑</el-button>
            <el-button type="danger" size="mini" class="el-icon-delete">编辑</el-button>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      categoriesList: [],
    };
  },
  created() {
    this.getCateGoriesList();
  },
  computed: {},
  methods: {
    async getCateGoriesList() {
      const { data: res } = await this.$http.get('categories');
      console.log(res);
      if (res.meta.status !== 200) {
        return this.$message.error("获取商品分类列表失败");
      }
      //提示获取权限列表成功
      this.$message.success("获取商品分类列表成功");
      this.categoriesList = res.data;
    },
  },
};
</script>
<style lang="less" scoped>
</style>
